package cn.memedai.router.matcher;

import android.app.Activity;
import android.content.Context;
import android.net.Uri;

import androidx.annotation.Nullable;

import java.util.Map;

import cn.memedai.router.RouteOptions;

/**
 * This matcher will generate an intent with an {@link android.content.Intent#ACTION_VIEW} action
 * and open a browser.
 * <p>
 * Created by Cheney on 2017/1/5.
 */
public class BrowserMatcher extends AbsImplicitMatcher {

    public BrowserMatcher(int priority) {
        super(priority);
    }

    @Override
    public MatcherResult match(Context context, Uri uri, @Nullable Map<String, Class<? extends Activity>> activityTable, RouteOptions routeOptions) {
        MatcherResult matcherResult = MatcherResult.newInstance();
        matcherResult.setMatch(uri.toString().toLowerCase().startsWith("http://")
                || uri.toString().toLowerCase().startsWith("https://"));
        return matcherResult;
    }
}
